<?php

class FireFeed_Acl_Acl extends Zend_Acl 
{
	public function __construct() 
	{
		
		//roles
		$this->addRole(new Zend_Acl_Role(FireFeed_Acl_Roles::GUEST));
		$this->addRole(new Zend_Acl_Role(FireFeed_Acl_Roles::USER));
		$this->addRole(new Zend_Acl_Role(FireFeed_Acl_Roles::ADMIN));
		
		//resources
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::INDEX));
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::USER));
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::CATEGORY));
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::FEED));
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::ADMIN));
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::AUTH));
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::REGISTRATION));
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::NEWS));
        $this->add(new Zend_Acl_Resource(FireFeed_Acl_Resources::TREE));
		
        /** RULES **/
        /* GUEST */
        $this->allow(FireFeed_Acl_Roles::GUEST,
        			 FireFeed_Acl_Resources::INDEX);
        $this->allow(FireFeed_Acl_Roles::GUEST,
                     FireFeed_Acl_Resources::REGISTRATION);
        $this->allow(FireFeed_Acl_Roles::GUEST,
                     FireFeed_Acl_Resources::AUTH);
        $this->allow(FireFeed_Acl_Roles::GUEST,
                     FireFeed_Acl_Resources::ADMIN,
                     FireFeed_Acl_Privileges::LOGIN);
        $this->allow(FireFeed_Acl_Roles::GUEST,
                     FireFeed_Acl_Resources::NEWS, 'upgradeindexboxnews');
        $this->deny(FireFeed_Acl_Roles::GUEST,
                    FireFeed_Acl_Resources::AUTH,
                    FireFeed_Acl_Privileges::LOGOUT);

		/* USER */                                       
		$this->allow(FireFeed_Acl_Roles::USER, FireFeed_Acl_Resources::INDEX);
		$this->deny(FireFeed_Acl_Roles::USER,
		            FireFeed_Acl_Resources::INDEX, 
		            FireFeed_Acl_Privileges::ADMIN);
		$this->allow(FireFeed_Acl_Roles::USER, FireFeed_Acl_Resources::FEED);
        $this->allow(FireFeed_Acl_Roles::USER, FireFeed_Acl_Resources::CATEGORY);
		$this->allow(FireFeed_Acl_Roles::USER, 
                     FireFeed_Acl_Resources::AUTH,
                     FireFeed_Acl_Privileges::LOGOUT);
        $this->allow(FireFeed_Acl_Roles::USER, 
                     FireFeed_Acl_Resources::USER,
                     FireFeed_Acl_Privileges::PROFILE);
        $this->allow(FireFeed_Acl_Roles::USER, 
                     FireFeed_Acl_Resources::USER,
                     FireFeed_Acl_Privileges::UPDATE_PROFILE);
        $this->allow(FireFeed_Acl_Roles::USER, 
                     FireFeed_Acl_Resources::TREE);
        $this->allow(FireFeed_Acl_Roles::USER, FireFeed_Acl_Resources::NEWS);
        $this->allow(FireFeed_Acl_Roles::USER,
                     FireFeed_Acl_Resources::USER,
                     FireFeed_Acl_Privileges::FEEDSUGGEST);             
		
		/* ADMIN */
        $this->allow(FireFeed_Acl_Roles::ADMIN, FireFeed_Acl_Resources::INDEX);
        $this->deny(FireFeed_Acl_Roles::ADMIN,
                    FireFeed_Acl_Resources::INDEX,
                    FireFeed_Acl_Privileges::USER);
        $this->deny(FireFeed_Acl_Roles::ADMIN,
                    FireFeed_Acl_Resources::AUTH,
                    FireFeed_Acl_Privileges::LOGIN_OPENID);
                                                
        $this->allow(FireFeed_Acl_Roles::ADMIN, FireFeed_Acl_Resources::ADMIN);
		$this->allow(FireFeed_Acl_Roles::ADMIN, FireFeed_Acl_Resources::USER);
		$this->deny(FireFeed_Acl_Roles::ADMIN, 
		            FireFeed_Acl_Resources::USER,
		            FireFeed_Acl_Privileges::FEEDSUGGEST);
		$this->allow(FireFeed_Acl_Roles::ADMIN, FireFeed_Acl_Resources::FEED);
		$this->allow(FireFeed_Acl_Roles::ADMIN, FireFeed_Acl_Resources::CATEGORY);
		$this->allow(FireFeed_Acl_Roles::ADMIN, 
		             FireFeed_Acl_Resources::AUTH,
		             FireFeed_Acl_Privileges::LOGOUT);
	}
}